<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

    <input type="text" id="input1" placeholder="请输入0-100之间的数">
    <input type="button" value="猜一猜" onclick="fun()">
    <div>结果<span>0</span></div>


<script>
/*0-100的随机数*/
    let maxs = parseInt(Math.random()*101);
    let cont= 0;

    let input1 = document.querySelector("#input1");
    let span = document.querySelector("span");
    function fun(){
        if(isNaN(input1)){
            span.innerText="输入错误";
            return;
        }
        cont++;
        if(maxs>input1.value){
            span.innerText = "猜小啦";
        }else if(maxs<input1.value){
            span.innerText = "猜大啦";
        }else if(maxs==input1.value){
            span.innerText = "猜对啦 第"+cont+'次结果为'+input1.value;
        }

    }
</script>

</body>
</html>